/**
 * outsider.com.cn Inc.
 * Copyright (c) 2011-2022 All Rights Reserved.
 */
package com.yuanmeng.common.core.enums;

import com.yuanmeng.common.core.exception.ServiceException;
import lombok.Getter;

/**
 * @author outsider
 * @version Id: StatusEnum.java, v 0.1 2022/6/1 17:16 outsider Exp $$
 */
@Getter
public enum ActiveTypeEnum {
    SPIKE("SPIKE", "秒杀", "1"),

    GROUP("GROUP", "拼团", "2"),

    POINT("POINT", "积分", "3"),

    OTHER("OTHER", "其他", "4");

    private String code;

    private String message;

    private String orderType;

    ActiveTypeEnum(String code, String message, String orderType) {
        this.code = code;
        this.message = message;
        this.orderType = orderType;
    }

    /**
     * 校验枚举值
     * @param activeType
     */
    public static void validateActiveType(String activeType) {
        int num = 0;
        for(ActiveTypeEnum ENUM : ActiveTypeEnum.values()) {
            if(ENUM.code.equals(activeType)) {
                num ++;
            }
        }
        if(num == 0) {
            throw new ServiceException("请求参数非法：活动类型参数异常！");
        }
    }

    /**
     * 获取活动类型
     * @param orderType
     */
    public static String getActiveCodeByOrderType(String orderType) {
        for(ActiveTypeEnum ENUM : ActiveTypeEnum.values()) {
            if(ENUM.orderType.equals(orderType)) {
                return ENUM.getCode();
            }
        }
        return "";
    }
}